home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / tool / dolmorph / src / guisub.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-19  |  22.7 KB  |  817 lines

  1. /*====================================================
  2.                       ARTemis
  3.                    (version 1.3)
  4.              FM-TOWNS 用ペイントツール
  5.  
  6.                  by 松内 良介 1994
  7. ====================================================*/
  8. /*
  9.     guisub.c
  10.         拡張ライブラリII をもっとラクに使うための補助関数群
  11.  
  12.     兄弟ウィンドウ関係の取得/設定
  13.     ウィンドウのユーザー枠の座標を得る
  14.     描画原点を(0,0)に設定/復帰
  15.     クリップ/ビジブル領域を画面全体に設定/復帰
  16.     12ドット文字表示
  17.  
  18.     int        RM_init(void)
  19.     void    RM_end(void)
  20.  
  21.     void    RM_getHyper(int objId, HYPER *hyp)
  22.     void    RM_getFrame(int idObj, FRAME *fr)
  23.     void    RM_setHyper(int objId, HYPER *hyp)
  24.     void    RM_setChColor(int objId, int col)
  25.     void    RM_moveCenter(int objId)
  26.     void    RM_getMoveFrame(FRAME *fr)
  27.  
  28.     void    RM_getWinUserFrame(int id, FRAME *user)
  29.  
  30.     void    RM_raise(int kobj)
  31.     int        RM_isTopInBros(int kobj)
  32.  
  33.     void    RM_setOriginZero(void)
  34.     void    RM_recoverOrigin(void)
  35.     void    RM_setClipVisibleAllScr(void)
  36.     void    RM_setClipAnyFrame(int id, FRAME *fr)
  37.     void    RM_recoverClipVisible(void)
  38.  
  39.     void    RM_adjustFrame(int kobj, int baseobj, FRAME *parm)
  40.     void    RM_adjustWinUser(int idWin, FRAME *parm)
  41.  
  42.     int        RM_callSimpleFDG(int baseId, int noselId,
  43.                              char *title,char *ok,char *cancel,
  44.                              char *wildext, int flag, char *pathbuf)
  45.     void    RM_putstring12(char *egbwork, int x,int y, char *str,
  46.                            int col, int bold)
  47.     void    RM_setScrollRange(int idSBar, int nDisp, int nAll, int bRedraw)
  48.     void    RM_setScrollPos(int idSBar, int nPos, int bRedraw)
  49.     int        RM_getScrollPos(int idSBar)
  50.     void    RM_setClipWinUser(int idWin, WINCLIP **clipstack)
  51.     void    RM_resetClipWinUser(WINCLIP *clipstack)
  52.     void    RM_roundFramePosition(int idWin, int nx, int ny)
  53.     void    RM_initRadioButton(int *idBtnAry, int btnNum, int *sel)
  54.     void    RM_pushRadioButton(int idBtn,int idBase,
  55.                                int *idBtnAry, int btnNum, int *sel)
  56.     void    RM_setMosCsr(int colorMode, int csrType)
  57.  
  58.     void    RM_setFileDlgStyle(int style)
  59.  
  60.  
  61. */
  62.  
  63. #include <stdio.h>
  64. #include <stdlib.h>
  65. #include <string.h>
  66. #include <winb.h>
  67. #include <te.h>
  68. #include <fntb.h>
  69. #include <gui.h>
  70. #include <file_dlg.h>
  71. #include <ctype.h>
  72. #include <fnt.h>
  73.  
  74. #include <egb.h>
  75. #include <wgb.h>
  76. #include <msdos.cf>
  77.  
  78. #include "guisub.h"
  79. #include "egbmac.h"
  80. #include "wgbmac.h"
  81.  
  82. #define    _iskanji(c)    (((c)&0xff) >= 0x81 && ((c)&0xff)<=0x9f || \
  83.                      ((c)&0xff) >= 0xe0 && ((c)&0xff)<=0xfc)
  84. #define    _iskanji1(kcode)    ((((kcode)>>8)&0xff) <= 0x97)
  85.  
  86. #define    WHITE    15
  87. #define    BLACK    8
  88. #define    WINBACK    6
  89. #define    RED        10
  90. #define    GRAY    7
  91.  
  92. /*--------------------------------------------------------*/
  93. /*                 このモジュールの初期化                 */
  94. /*--------------------------------------------------------*/
  95.  
  96.     static    int        font12seg;                // 12dot font が存在するセグメント
  97.  
  98.     int RM_init(void)
  99.     {
  100.         extern int mma_allocSeg(char* segname);
  101.         font12seg = mma_allocSeg("FONT");
  102.         return 0;
  103.     }
  104.     
  105.     void RM_end(void)
  106.     {
  107.     }
  108.  
  109. /*--------------------------------------------------------*/
  110. /*                ハイパー/枠の設定・取得                */
  111. /*--------------------------------------------------------*/
  112.  
  113.     void RM_getHyper(int objId, HYPER *hyp)
  114.     {
  115.         MMI_SendMessage(objId, MM_GETHYPER, 1, hyp);
  116.     }
  117.  
  118.     void RM_getFrame(int idObj, FRAME *fr)
  119.     {
  120.         HYPER hyp;
  121.         MMI_SendMessage(idObj, MM_GETHYPER, 1, &hyp);
  122.         *fr = hyp.fr;
  123.     }
  124.  
  125.     void RM_setHyper(int objId, HYPER *hyp)
  126.     {
  127.         MMI_SendMessage(objId, MM_SETHYPER, 1, hyp);
  128.     }
  129.  
  130.     void RM_setChColor(int idObj, int col)
  131.     {
  132.         HYPER hyp;
  133.         MMI_SendMessage(idObj, MM_GETHYPER, 1, &hyp);
  134.         hyp.clr.ch = col;
  135.         MMI_SendMessage(idObj, MM_SETHYPER, 1, &hyp);
  136.     }
  137.  
  138.     void RM_moveCenter(int objId)
  139.     {
  140.         HYPER h;
  141.         FRAME fr,frScr;
  142.         WINCTRL *pCtrl;
  143.         int wid,ht;
  144.         MMI_GetControl(&pCtrl);
  145.         frScr = pCtrl->bound;
  146.         MMI_SendMessage(objId, MM_GETHYPER, 1, &h);
  147.         wid = h.fr.rdwx - h.fr.lupx + 1;
  148.         ht  = h.fr.rdwy - h.fr.lupy + 1;
  149.         fr.lupx = ((frScr.rdwx - frScr.lupx+1) - wid) / 2;
  150.         fr.lupy = ((frScr.rdwy - frScr.lupy+1) - ht ) / 2;
  151.         fr.rdwx = fr.lupx + wid - 1;
  152.         fr.rdwy = fr.lupy + ht  - 1;
  153.         MMI_SendMessage(objId, MM_MOVE, 1, &fr);
  154.     }
  155.  
  156.     void RM_getMoveFrame(FRAME *fr)
  157.     {
  158.         WINCTRL *ctrl;
  159.         MMI_GetControl(&ctrl);
  160.         if (fr != NULL)
  161.             *fr = ctrl->move;
  162.     }
  163.  
  164. /*--------------------------------------------------------*/
  165. /*             兄弟ウィンドウ関係の取得/設定             */
  166. /*--------------------------------------------------------*/
  167.  
  168.     void RM_raise(int kobj)
  169.     /* 兄弟ウィンドウ内で一番上にもってくる */
  170.     {
  171.         int base;
  172.         base = TL_getObjectPtr(kobj)->base;
  173.         if (base < 0)
  174.             return;
  175.         MMI_SendMessage(kobj, MM_DETACH, 0);
  176.         MMI_SendMessage(kobj, MM_ATTACH, 2, base, -1) ;
  177.     }
  178.  
  179.     int    RM_isTopInBros(int kobj)
  180.     /* 兄弟ウィンドウ内で一番上かどうかを調べる */
  181.     {
  182.         OBJECT *pobj,*pbase;
  183.         pobj = TL_getObjectPtr(kobj);
  184.         pbase = TL_getObjectPtr(pobj->base);
  185.         if (pbase->slave == pobj->llevel)
  186.             return 1;
  187.         else
  188.             return 0;
  189.     }
  190.  
  191. /*--------------------------------------------------------*/
  192. /*           ウィンドウのユーザー枠の座標を得る           */
  193. /*--------------------------------------------------------*/
  194.  
  195.     void RM_getWinUserFrame(int id, FRAME *user)
  196.     {
  197.         HYPER hyp;
  198.         FRAME frUser,frResize;
  199.         MMI_SendMessage(id, MM_GETUSER, 2, &frUser, &frResize);
  200.         MMI_SendMessage(id, MM_GETHYPER, 1, &hyp);
  201.         frUser.lupx += hyp.fr.lupx;
  202.         frUser.lupy += hyp.fr.lupy;
  203.         frUser.rdwx = frUser.lupx + frUser.rdwx - 1;
  204.         frUser.rdwy = frUser.lupy + frUser.rdwy - 1;
  205.         if (user != NULL)
  206.             *user = frUser;
  207.     }
  208.  
  209. /*--------------------------------------------------------*/
  210. /*              描画原点を(0,0)に設定/復帰               */
  211. /*--------------------------------------------------------*/
  212.  
  213.     typedef struct stag_orig {
  214.         struct stag_orig    *next;
  215.         POINT                ptOrigStack;
  216.     } ORIGSTACK;
  217.  
  218.     static ORIGSTACK *ostack = NULL;
  219.  
  220.     void RM_setOriginZero(void)
  221.     {
  222.         static POINT ptNewOrig = {0,0};
  223.         ORIGSTACK *pos;
  224.         pos = TL_calloc(1, sizeof(ORIGSTACK));
  225.         pos->next = ostack;
  226.         ostack = pos;
  227.         MG_PushOrigin(&ptNewOrig, &pos->ptOrigStack);
  228.     }
  229.  
  230.     void RM_recoverOrigin(void)
  231.     {
  232.         ORIGSTACK *pos;
  233.         pos = ostack;
  234.         ostack = ostack->next;
  235.         MG_PopOrigin(&pos->ptOrigStack);
  236.         TL_free(pos);
  237.     }
  238.  
  239. /*--------------------------------------------------------*/
  240. /*      クリップ/ビジブル領域を画面全体に設定/復帰      */
  241. /*--------------------------------------------------------*/
  242.  
  243.     typedef struct _tag_cvstack {
  244.         struct _tag_cvstack    *next;
  245.         WINCLIP             *pwcClipStack;
  246.         WINCLIP             *pwcVisibleStack;
  247.         int                    type;
  248.     } CVSTACK;
  249.  
  250.     #define    STACK_PUSHCLIP        0
  251.     #define    STACK_BEGINUPDATE    1
  252.  
  253.     static CVSTACK *cvstack = NULL;
  254.  
  255.     void RM_setClipVisibleAllScr(void)
  256.     {
  257.         CVSTACK *pcv;
  258.         FRAME frAllScr;
  259.         WINCLIP *pWinClip;
  260.         WINCTRL *pWinCtrl;
  261.       /* 画面全体を表す WINCLIP リストを作成 */
  262.         MMI_GetControl(&pWinCtrl);
  263.         frAllScr = pWinCtrl->bound;
  264.         pWinClip = WIN_getClipMemory(&frAllScr, NULL);
  265.       /* CVSTACKを作成、リストに追加 */
  266.         pcv = TL_calloc(1, sizeof(CVSTACK));
  267.         pcv->next = cvstack;
  268.         cvstack = pcv;
  269.       /* pWinClip をクリップ領域・ビジブル領域として設定 */
  270.         WIN_pushVisible(WIN_copyClip(pWinClip), &(pcv->pwcVisibleStack));
  271.         WIN_pushClip(pWinClip, &(pcv->pwcClipStack));
  272.         pcv->type = STACK_PUSHCLIP;
  273.     }
  274.  
  275.     void RM_setClipAnyFrame(int id, FRAME *fr)
  276.     {
  277.         CVSTACK *pcv;
  278.       /* CVSTACKを作成、リストに追加 */
  279.         pcv = TL_calloc(1, sizeof(CVSTACK));
  280.         pcv->next = cvstack;
  281.         cvstack = pcv;
  282.       /* クリップ領域を設定 */
  283.         pcv->pwcVisibleStack = NULL;
  284.         HYPER hyp;
  285.         FRAME frBackup;
  286.         RM_getHyper(id, &hyp);
  287.         frBackup = hyp.fr;
  288.         hyp.fr = *fr;
  289.         RM_setHyper(id, &hyp);
  290.         WIN_beginUpDateObj(id, &(pcv->pwcClipStack));
  291.         hyp.fr = frBackup;
  292.         RM_setHyper(id, &hyp);
  293.         pcv->type = STACK_BEGINUPDATE;
  294.     }
  295.  
  296.     void RM_recoverClipVisible(void)
  297.     {
  298.         CVSTACK *pcv;
  299.         pcv = cvstack;
  300.         cvstack = cvstack->next;
  301.         if (pcv->type == STACK_PUSHCLIP)
  302.         {
  303.             if (pcv->pwcClipStack != NULL)
  304.                 WIN_popClip(pcv->pwcClipStack);
  305.             if (pcv->pwcVisibleStack != NULL)
  306.                 WIN_popVisible(pcv->pwcVisibleStack);
  307.         }
  308.         else if (pcv->type == STACK_BEGINUPDATE)
  309.         {
  310.             if (pcv->pwcClipStack != NULL)
  311.                 WIN_endUpDateObj(pcv->pwcClipStack);
  312.             if (pcv->pwcVisibleStack != NULL)
  313.                 WIN_popVisible(pcv->pwcVisibleStack);
  314.         }
  315.         TL_free(pcv);
  316.     }
  317.  
  318. /*--------------------------------------------------------*/
  319. /*       他の部品をベースに部品の位置・大きさを設定       */
  320. /*--------------------------------------------------------*/
  321.  
  322.     void RM_adjustFrame(int kobj, int baseobj, FRAME *parm)
  323.     {
  324.         HYPER hyp, hypBase;
  325.         MMI_SendMessage(kobj, MM_GETHYPER, 1, &hyp);
  326.         MMI_SendMessage(baseobj, MM_GETHYPER, 1, &hypBase);
  327.         #define    DO(t1, t2, t3)                                \
  328.             if (parm->t1 >= 0)                                \
  329.                 hyp.fr.t1 = hypBase.fr.t2 + parm->t1;        \
  330.             else                                            \
  331.                 hyp.fr.t1 = hypBase.fr.t3 + 1 + parm->t1;
  332.         DO(lupx, lupx, rdwx)
  333.         DO(lupy, lupy, rdwy)
  334.         DO(rdwx, lupx, rdwx)
  335.         DO(rdwy, lupy, rdwy)
  336.         #undef DO
  337.         MMI_SendMessage(kobj, MM_SETHYPER, 1, &hyp);
  338.     }
  339.  
  340.     void RM_adjustWinUser(int idWin, FRAME *parm)
  341.     {
  342.         HYPER hyp;
  343.         FRAME frUser, frResize;
  344.         MMI_SendMessage(idWin, MM_GETHYPER, 1, &hyp);
  345.         MMI_SendMessage(idWin, MM_GETUSER, 2, &frUser, &frResize);
  346.         #define    DO(t1, t2, t3)                            \
  347.             if (parm->t1 >= 0)                            \
  348.                 frUser.t1 = hyp.fr.t2 + parm->t1;        \
  349.             else                                        \
  350.                 frUser.t1 = hyp.fr.t3 + 1 + parm->t1;
  351.         DO(lupx, lupx, rdwx)
  352.         DO(lupy, lupy, rdwy)
  353.         DO(rdwx, lupx, rdwx)
  354.         DO(rdwy, lupy, rdwy)
  355.         #undef DO
  356.         frUser.rdwx = frUser.rdwx - frUser.lupx + 1;
  357.         frUser.rdwy = frUser.rdwy - frUser.lupy + 1;
  358.         frUser.lupx = frUser.lupx - hyp.fr.lupx;
  359.         frUser.lupy = frUser.lupy - hyp.fr.lupy;
  360.         MMI_SendMessage(idWin, MM_SETUSER, 1, &frUser, &frResize);
  361.     }
  362.  
  363. /*--------------------------------------------------------*/
  364. /*              ファイルダイアログの呼び出し              */
  365. /*--------------------------------------------------------*/
  366.  
  367.     int RM_callSimpleFDG(int baseId, int noselId,
  368.                          char *title,char *ok,char *cancel,
  369.                          char *wildext, int flag, char *pathbuf)
  370.     /*
  371.         flag: FDG_NONE, FDG_MSLCT, FDG_TEXT, FDG_FILEONLY など
  372.         FDG_MSLCT を指定している場合、*(int*)pathbuf にファイルの個数
  373.         (返値が0でないときは無効)
  374.     */
  375.     {
  376.         static char *extstr[] = {"*.*",NULL};
  377.         int atr,ret,i;
  378.         unsigned int select_cnt;
  379.         char pathname[80];
  380.         if (wildext != NULL)
  381.             extstr[0] = wildext;
  382.         else
  383.             extstr[0] = "*.*";
  384.       /* ファイルダイアログ以外の部品を選択不可にする */
  385.         MTL_setFlagObj(noselId, MS_UNSELECT) ;
  386.       /* ファイルダイアログのタイトル、表示位置を設定 */
  387.         FDG_SetTitle(title, ok, cancel) ;
  388.         HYPER h;
  389.         FRAME fr;
  390.         MMI_SendMessage(FDG_GetMainID(), MM_GETHYPER, 1, &h);
  391.         fr.lupx = (640 - (h.fr.rdwx - h.fr.lupx + 1)) / 2;
  392.         fr.lupy = (480 - (h.fr.rdwy - h.fr.lupy + 1)) / 2;
  393.         FDG_SetFrame(fr);
  394.       /* ファイルダイアログの表示 */
  395.         ret = FDG_DspFileDlg(baseId, flag,NULL,extstr,&select_cnt);
  396.       /* 「実行」が押されたならファイル名を取得 */
  397.         if (ret > 0)
  398.         {
  399.             if (flag & FDG_MSLCT)
  400.                 *(int*)pathbuf = select_cnt;
  401.             else
  402.             {
  403.                 FDG_GetPathName(pathname, &atr, 0);
  404.                 strcpy(pathbuf, pathname);
  405.             }
  406.         }
  407.       /* ファイルダイアログ以外の部品を選択可能にもどす */
  408.         MTL_resetFlagObj(noselId, ~MS_UNSELECT) ;
  409.       /* リターン */
  410.         if (ret > 0)
  411.             return 0;
  412.         else
  413.             return -1;
  414.     }
  415.  
  416. /*--------------------------------------------------------*/
  417. /*                   12ドット文字表示                   */
  418. /*--------------------------------------------------------*/
  419.  
  420.     void RM_putstring12(char *egbwork,int x,int y,char *str, int col,int bold)
  421.         /* グローバル変数 font12seg の設定が必要 */
  422.     {
  423.         #define    PUTBITBLOCK(x1,y1,x2,y2,dat) {                        \
  424.             char para[16];                                            \
  425.             DWORD(para)=(unsigned int)dat; WORD(para+4)=getds();    \
  426.             WORD(para+6)=x1; WORD(para+8)=y1;                        \
  427.             WORD(para+10)=x2; WORD(para+12)=y2;                        \
  428.             WGB_putBlockColor(egbwork, 1, para); }
  429.         int ds = getds();
  430.         char fontbuf[24];
  431.         EGB_color(egbwork, 0, col);
  432.         EGB_writeMode(egbwork, 0);
  433.         while (*str != 0)
  434.         {
  435.             if (_iskanji(*str))
  436.               /* 全角文字の場合 */
  437.             {
  438.                 int ofs, sjis = (*str)*256 + *(str+1), jis;
  439.                 jis = FNT_sjisToJis(sjis);
  440.                 if (_iskanji1(sjis))
  441.                 {
  442.                     ofs = ( ((jis>>8)-0x21)*94 + (jis&0xff) - 0x21)*24 + 0xc00;
  443.                     _movedata(font12seg, ofs, ds, (unsigned int)fontbuf, 24);
  444.                 }
  445.                 else    // 第1水準じゃない場合
  446.                 {
  447.                     char font16buf[32];
  448.                     FNT_kanjiRead(16,16,jis,ds,font16buf);
  449.                     memset(fontbuf,0,24);
  450.                     int di=0;
  451.                     for (int i=0; i<16; i++)
  452.                     {
  453.                         unsigned short p;
  454.                         p = ((unsigned short)font16buf[i*2]<<8) |
  455.                             font16buf[i*2+1];
  456.                         p =  (p&0xc000) | ((p&0x3c00)<<1) | ((p&0x3c0)<<2) |
  457.                             ((p&0x3c)<<3) | ((p&0x3)<<4);
  458.                         fontbuf[di*2]   |= (p>>8) & 0xff;
  459.                         fontbuf[di*2+1] |= p & 0xff;
  460.                         if (i!=1 && i!=4 && i!=7 && i!=10)
  461.                             di++;
  462.                     }
  463.                 }
  464.                 PUTBITBLOCK(x,y,x+11,y+11,fontbuf);
  465.                 str++,str++;
  466.                 x += 12;
  467.             }
  468.             else
  469.               /* ANK文字の場合 */
  470.             {
  471.                 if (*str != ' ')
  472.                 {
  473.                     int ofs = (int)*str * 12;
  474.                     _movedata(font12seg, ofs, ds, (unsigned int)fontbuf, 12);
  475.                     PUTBITBLOCK(x,y,x+5,y+11,fontbuf);
  476.                 }
  477.                 str++;
  478.                 x += 6;
  479.             }
  480.         }
  481.     }
  482.  
  483. /*--------------------------------------------------------*/
  484. /*              スクロールバー値の設定/取得              */
  485. /*--------------------------------------------------------*/
  486.  
  487.     void    RM_setScrollRange(int idSBar, int nDisp, int nAll, int bRedraw)
  488.     {
  489.         int ptr,min,max,len,page;
  490.         MMI_SendMessage(idSBar, MM_GETSCROLL, 5, &ptr,&min,&max,&len,&page);
  491.         min = nDisp-1;
  492.         max = nAll < nDisp ? nDisp-1 : nAll-1;
  493.         ptr = _max(min, _min(max, ptr));
  494.         MMI_SendMessage(idSBar, MM_SETSCROLL, 5, ptr,min,max, nDisp, page);
  495.         if (bRedraw)
  496.             MMI_SendMessage(idSBar, MM_SHOW, 0);
  497.     }
  498.  
  499.     void    RM_setScrollPos(int idSBar, int nPos, int bRedraw)
  500.     {
  501.         int ptr,min,max,len,page;
  502.         MMI_SendMessage(idSBar, MM_GETSCROLL, 5, &ptr,&min,&max,&len,&page);
  503.         ptr = _max(min, _min(max, min + nPos));
  504.         MMI_SendMessage(idSBar, MM_SETSCROLL, 5, ptr,min,max, len, page);
  505.         if (bRedraw)
  506.             MMI_SendMessage(idSBar, MM_SHOW, 0);
  507.     }
  508.  
  509.     int        RM_getScrollPos(int idSBar)
  510.     {
  511.         int ptr,min,max,len,page;
  512.         MMI_SendMessage(idSBar, MM_GETSCROLL, 5, &ptr,&min,&max,&len,&page);
  513.         return ptr - min;
  514.     }
  515.  
  516. /*--------------------------------------------------------*/
  517. /*        ウィンドウのユーザー領域にクリップを設定        */
  518. /*--------------------------------------------------------*/
  519.  
  520.     void RM_setClipWinUser(int idWin, WINCLIP **clipstack)
  521.     {
  522.         HYPER hyp;
  523.         FRAME frUser,frBackup;
  524.         RM_getHyper(idWin, &hyp);
  525.         frBackup = hyp.fr;
  526.         RM_getWinUserFrame(idWin, &frUser);
  527.         hyp.fr = frUser;
  528.         RM_setHyper(idWin, &hyp);
  529.         WIN_beginUpDateObj(idWin, clipstack);
  530.         hyp.fr = frBackup;
  531.         RM_setHyper(idWin, &hyp);
  532.     }
  533.  
  534.     void RM_resetClipWinUser(WINCLIP *clipstack)
  535.     {
  536.         WIN_endUpDateObj(clipstack);
  537.     }
  538.  
  539. /*--------------------------------------------------------*/
  540. /*           ウィンドウの座標を n の倍数に補正            */
  541. /*--------------------------------------------------------*/
  542.  
  543.     void RM_roundFramePosition(int idWin, int nx, int ny)
  544.     {
  545.         HYPER hyp;
  546.         MG_mosDisp(2);
  547.         RM_getHyper(idWin, &hyp);
  548.         int dx,dy;
  549.         dx = -(hyp.fr.lupx % nx);
  550.         dy = -(hyp.fr.lupy % ny);
  551.         if (dx != 0 || dy != 0)
  552.             WIN_moveWindow(idWin, dx,dy);
  553.         MG_mosDisp(3);
  554.     }
  555.  
  556. /*--------------------------------------------------------*/
  557. /*                    ラジオボタン処理                    */
  558. /*--------------------------------------------------------*/
  559.  
  560.     void RM_initRadioButton(int *idBtnAry, int btnNum, int *sel)
  561.     {
  562.         int i;
  563.         for (i=0; i<btnNum; i++)
  564.             MTL_resetFlagObj(idBtnAry[i], ~(MS_UNSELECT|MS_TOGGLE)) ;
  565.         // MTL_setFlagObj(idBtnAry[*sel], (MS_UNSELECT|MS_TOGGLE)) ;
  566.         MTL_setFlagObj(idBtnAry[*sel], MS_TOGGLE) ;
  567.     }
  568.  
  569.     void RM_pushRadioButton(int idBtn,int idBase,
  570.                             int *idBtnAry, int btnNum, int *sel)
  571.     {
  572.         WINCLIP *clip;
  573.         int i;
  574.         for (i=0 ; i<btnNum; i++)
  575.             if (idBtnAry[i] == idBtn)
  576.                 break;
  577.         if (*sel != i)
  578.         {
  579.             WIN_beginUpDateObj(idBase, &clip);
  580.             // MTL_resetFlagObj(idBtnAry[*sel], ~(MS_UNSELECT|MS_TOGGLE)) ;
  581.             MTL_resetFlagObj(idBtnAry[*sel], ~MS_TOGGLE) ;
  582.             MMI_SendMessage(idBtnAry[*sel], MM_SHOW, 0) ;
  583.             *sel = i;
  584.             // MTL_setFlagObj(idBtnAry[*sel], (MS_UNSELECT|MS_TOGGLE)) ;
  585.             MTL_setFlagObj(idBtnAry[*sel], MS_TOGGLE) ;
  586.             WIN_endUpDateObj(clip);
  587.         }
  588.         else
  589.         {
  590.             WIN_beginUpDateObj(idBase, &clip);
  591.             MTL_setFlagObj(idBtnAry[*sel], MS_TOGGLE) ;
  592.             MMI_SendMessage(idBtnAry[*sel], MM_SHOW, 0) ;
  593.             WIN_endUpDateObj(clip);
  594.         }
  595.     }
  596.  
  597. /*--------------------------------------------------------*/
  598. /*                マウスカーソル形状の設定                */
  599. /*--------------------------------------------------------*/
  600.  
  601.     void RM_setMosCsr(int colorMode, int csrType)
  602.     {
  603.         unsigned int *coltbl;
  604.         coltbl = MG_getColorTable(colorMode);
  605.         if (colorMode == 0)
  606.             SetMouse16(csrType, WHITE, BLACK);
  607.         else if (colorMode == 1)
  608.             SetMouse16(csrType, coltbl[WHITE] & 0xff, coltbl[BLACK] & 0xff);
  609.         else if (colorMode == 2)
  610.             SetMouse16(csrType, coltbl[WHITE]&0x7fff, coltbl[BLACK]&0x7fff);
  611.     }
  612.  
  613. /*--------------------------------------------------------*/
  614. /*               メタID からクラス名を得る                */
  615. /*--------------------------------------------------------*/
  616.  
  617.     char *RM_getMetaIdName(int metaId)
  618.     {
  619.         char *typename;
  620.         if (metaId == MJ_DIALOGL40)
  621.             typename = "ダイアログ型";
  622.         else if (metaId == MJ_HYPER)
  623.             typename = "ハイパー型";
  624.         else if (metaId == MJ_ALERTL40)
  625.             typename = "アラート型";
  626.         else if (metaId == MJ_WINDOWL40)
  627.             typename = "ウィンドウ型";
  628.         else if (metaId == MJ_MSGL40)
  629.             typename = "メッセージ型";
  630.         else if (metaId == MJ_MENUL40)
  631.             typename = "メニュー型";
  632.         else if (metaId == MJ_BUTTONL40)
  633.             typename = "ボタン型";
  634.         else if (metaId == MJ_DBUTTONL40)
  635.             typename = "ドローボタン型";
  636.         else if (metaId == MJ_ICONL40)
  637.             typename = "アイコンボタン型";
  638.         else if (metaId == MJ_TICONL40)
  639.             typename = "トグルアイコン型";
  640.         else if (metaId == MJ_MITEML40)
  641.             typename = "メニューアイテム型";
  642.         else if (metaId == MJ_SCRLL40)
  643.             typename = "スクロールバー型";
  644.         else if (metaId == MJ_TEXTL40)
  645.             typename = "テキスト型";
  646.         else if (metaId == MJ_LMENUL40)
  647.             typename = "リストメニュー型";
  648.         else if (metaId == MJ_NUMBOXL40)
  649.             typename = "数値入力パネル型";
  650.         else
  651.             typename = "<不明>";
  652.         return typename;
  653.     }
  654.  
  655. /*--------------------------------------------------------*/
  656. /*          ファイルダイアログの見た目を変更する          */
  657. /*--------------------------------------------------------*/
  658.  
  659. #if 0
  660.     static void FDGdump(void)
  661.     {
  662.         int idWin;
  663.         idWin = FDG_GetMainID();
  664.         int depth = 0;
  665.         void dumpObj(int id)
  666.         {
  667.             void indent(void)
  668.             {
  669.                 int i;
  670.                 for (i=0; i<depth; i++)
  671.                     printf("|  ");
  672.             }
  673.             OBJECT *pObj, *pBase;
  674.             if (id <= 0 || (pObj = TL_getObjectPtr(id)) == NULL)
  675.                 { printf("*** no there %d ***\n",id); return; }
  676.             pBase = (pObj->base > 0 ? TL_getObjectPtr(pObj->base) : NULL);
  677.             indent();
  678.             printf("┌Obj %4d %-20s\n", id,RM_getMetaIdName(pObj->meta));
  679.             HYPER hyp;
  680.             hyp = *(HYPER*)pObj->data;
  681.             indent();
  682.             printf("│  fr(%3d,%3d)-(%3d,%3d) ", hyp.fr.lupx, hyp.fr.lupy,
  683.                     hyp.fr.rdwx, hyp.fr.rdwy);
  684.             printf("col(%d,%d,%d)\n", hyp.clr.fr, hyp.clr.back, hyp.clr.ch);
  685.             indent();
  686.             printf("└  base,slave,left,right=(%d,%d,%d,%d)\n",
  687.                     pObj->base,pObj->slave,pObj->llevel,pObj->rlevel);
  688.             if (pObj->slave > 0)
  689.                 { depth++; dumpObj(pObj->slave); depth--; }
  690.             if (pBase != NULL)
  691.                 if (pObj->llevel > 0 && pObj->llevel != pBase->slave)
  692.                     dumpObj(pObj->llevel);
  693.         }
  694.         dumpObj(idWin);
  695.     }
  696. #endif
  697.  
  698. #if 1
  699.     void FDGdump(void)
  700.     {
  701.         int idWin;
  702.         idWin = MJ_BASEOBJ;
  703.         int depth = 0;
  704.         void dumpObj(int id)
  705.         {
  706.             if (depth >= 2)
  707.                 return;
  708.             void indent(void)
  709.             {
  710.                 int i;
  711.                 for (i=0; i<depth; i++)
  712.                     printf("|  ");
  713.             }
  714.             OBJECT *pObj, *pBase;
  715.             if (id <= 0 || (pObj = TL_getObjectPtr(id)) == NULL)
  716.                 { printf("*** no there %d ***\n",id); return; }
  717.             pBase = (pObj->base > 0 ? TL_getObjectPtr(pObj->base) : NULL);
  718.             indent();
  719.             printf("┌Obj %4d %-20s\n", id,RM_getMetaIdName(pObj->meta));
  720.             HYPER hyp;
  721.             hyp = *(HYPER*)pObj->data;
  722.             indent();
  723.             printf("│  fr(%3d,%3d)-(%3d,%3d) ", hyp.fr.lupx, hyp.fr.lupy,
  724.                     hyp.fr.rdwx, hyp.fr.rdwy);
  725.             printf("col(%d,%d,%d)\n", hyp.clr.fr, hyp.clr.back, hyp.clr.ch);
  726.             indent();
  727.             printf("└  base,slave,left,right=(%d,%d,%d,%d)\n",
  728.                     pObj->base,pObj->slave,pObj->llevel,pObj->rlevel);
  729.             if (pObj->slave > 0)
  730.                 { depth++; dumpObj(pObj->slave); depth--; }
  731.             if (pBase != NULL)
  732.                 if (pObj->llevel > 0 && pObj->llevel != pBase->slave)
  733.                     dumpObj(pObj->llevel);
  734.         }
  735.         dumpObj(idWin);
  736.     }
  737. #endif
  738.  
  739. void RM_setFileDlgStyle(int style)
  740. {
  741.     typedef struct
  742.     {
  743.         int        objId;
  744.         COLOR    clr;        /* 設定したい表示色 */
  745.         int        atrm;        /* 設定したい表示属性 */
  746.         FRAME    fr;            /* フレーム変更(相対値) */
  747.     } PARTCHANGE;
  748.     static PARTCHANGE change[] =
  749.     {
  750.         #define    FR0        {0,0,0,0}
  751.         #define STYLE   {BLACK,WINBACK,BLACK}, MS_FRAMEL40|MS_UFRAMEL40
  752.         #define    STYLE2    {BLACK,BLACK,WHITE}, MS_FRAMEL40|MS_DFRAMEL40
  753.         #define STYLE3  {BLACK,WINBACK,WINBACK}, MS_FRAMEL40|MS_UFRAMEL40
  754.         #define    STYLE4    {BLACK,WINBACK,WINBACK}, MS_FRAMEL40|MS_BFRAMEL40|MS_PANELL40
  755.         #define    BK        BLACK
  756.         #define    MSGSTYLE2    {BK,WINBACK,BK},MS_OPAQUEL40
  757.         { FDG_MAINDLG,  STYLE, FR0 },
  758.         { FDG_TITLE1,   STYLE, {1,1,1,0} },
  759.         { FDG_TITLE2,   STYLE, {1,1,1,0} },
  760.         { FDG_TITLEMSG, MSGSTYLE2,{1,1,1,1} },
  761.         { FDG_CLSBTN,   STYLE3, {0,0,2,2} },
  762.         { FDG_DRVSLCTL, STYLE, FR0 },    // ドライブ選択←
  763.         { FDG_DRVSLCTR, STYLE, FR0 },    // ドライブ選択→
  764.         { FDG_DRVICON,  STYLE, FR0 },
  765.         { FDG_ALLDRVBTN,STYLE, FR0 },    // SHOW ALL 背景
  766.         { FDG_ALLDRVDLG,STYLE, FR0 },    // SHOW ALL 背景
  767.         { FDG_VOLLABEL, MSGSTYLE2,FR0 },
  768.         { FDG_FREESIZE, MSGSTYLE2,FR0 },
  769.         { FDG_CURDIR,   STYLE2, FR0 },
  770.         { FDG_MOVEDIR,  STYLE, FR0 },
  771.         { FDG_UPDIR,    STYLE, FR0 },
  772.         { FDG_LMENU,    STYLE2, FR0 },
  773.         { FDG_SCRLBAR,  STYLE4, FR0 },
  774.         { FDG_FNAMETXT, {RED,BK,WHITE},MS_FRAMEL40|MS_DFRAMEL40, FR0 },
  775.         { FDG_EXECBTN,  STYLE, FR0 },
  776.         { FDG_CNCLBTN,  STYLE, FR0 },
  777.         { -1 }
  778.     };
  779.     PARTCHANGE *pc;
  780.     for (pc = change;  pc->objId >= 0;  pc++)
  781.     {
  782.         HYPER hyp;
  783.         FDG_GetObjData(pc->objId, &hyp);
  784.         hyp.atrm = pc->atrm;
  785.         hyp.clr = pc->clr;
  786.         hyp.fr.lupx += pc->fr.lupx;
  787.         hyp.fr.lupy += pc->fr.lupy;
  788.         hyp.fr.rdwx += pc->fr.rdwx;
  789.         hyp.fr.rdwy += pc->fr.rdwy;
  790.         FDG_SetObjData(pc->objId, &hyp);
  791.     }
  792. }
  793.  
  794. /*--------------------------------------------------------*/
  795. /*          オリジナル・ビジュアルエフェクト関数          */
  796. /*--------------------------------------------------------*/
  797.  
  798. void MS_ve(int num, int flag, FRAME *fr, char *ptr)
  799. {
  800.     if (flag == TRUE)
  801.     {
  802.         int ve = (num / 100) % 100;
  803.         if (num == 9)
  804.         /*  斜め線転送! 今は16色モードのみ。*/
  805.         {
  806.             
  807.         }
  808.     }
  809.     else
  810.     {
  811.         int ve = num % 100;
  812.     }
  813. }
  814.  
  815.  
  816.  
  817.